package com.mazaiting.emotion.util

import android.util.ArrayMap
import com.mazaiting.emotion.R
import com.mazaiting.log.L
import java.util.Collections.EMPTY_MAP

/***
 *
 *
 *                                                    __----~~~~~~~~~~~------___
 *                                   .  .   ~~//====......          __--~ ~~
 *                   -.            \_|//     |||\\  ~~~~~~::::... /~
 *                ___-==_       _-~o~  \/    |||  \\            _/~~-
 *        __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *    _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *  .~       .~       |   \\ -_    /  /-   /   ||      \   /
 * /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 * |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *          '         ~-|      /|    |-~\~~       __--~~
 *                      |-~~-_/ |    |   ~\_   _-~            /\
 *                           /  \     \__   \/~                \__
 *                       _--~ _/ | .-~~____--~-/                  ~~==.
 *                      ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                 -_     ~\      ~~---l__i__i__i--~~_/
 *                                 _-~-__   ~)  \--______________--~~
 *                               //.-~~~-~_--~- |-------~~~~~~~~
 *                                      //.-~~~--\
 *                               神兽保佑
 *                              代码无BUG!
 * @author mazaiting
 * @date 2019-08-08
 * @description 表情工具类
 */
object EmotionUtil {

    /**
     * 表情类型标志符_经典表情
     */
    const val EMOTION_CLASSIC_TYPE = 0x0001

    /**
     * key-表情文字;
     * value-表情图片资源
     */
    private val EMPTY_MAP: ArrayMap<String, Int> = ArrayMap()
    /**
     * key-表情文字;
     * value-表情图片资源
     */
    private val EMOTION_CLASSIC_MAP: ArrayMap<String, Int> = ArrayMap()

    init {
        EMOTION_CLASSIC_MAP["[呵呵]"] = R.drawable.d_hehe
        EMOTION_CLASSIC_MAP["[嘻嘻]"] = R.drawable.d_xixi
        EMOTION_CLASSIC_MAP["[哈哈]"] = R.drawable.d_haha
        EMOTION_CLASSIC_MAP["[爱你]"] = R.drawable.d_aini
        EMOTION_CLASSIC_MAP["[挖鼻屎]"] = R.drawable.d_wabishi
        EMOTION_CLASSIC_MAP["[吃惊]"] = R.drawable.d_chijing
        EMOTION_CLASSIC_MAP["[晕]"] = R.drawable.d_yun
        EMOTION_CLASSIC_MAP["[泪]"] = R.drawable.d_lei
        EMOTION_CLASSIC_MAP["[馋嘴]"] = R.drawable.d_chanzui
        EMOTION_CLASSIC_MAP["[抓狂]"] = R.drawable.d_zhuakuang
        EMOTION_CLASSIC_MAP["[哼]"] = R.drawable.d_heng
        EMOTION_CLASSIC_MAP["[可爱]"] = R.drawable.d_keai
        EMOTION_CLASSIC_MAP["[怒]"] = R.drawable.d_nu
        EMOTION_CLASSIC_MAP["[汗]"] = R.drawable.d_han
        EMOTION_CLASSIC_MAP["[害羞]"] = R.drawable.d_haixiu
        EMOTION_CLASSIC_MAP["[睡觉]"] = R.drawable.d_shuijiao
        EMOTION_CLASSIC_MAP["[钱]"] = R.drawable.d_qian
        EMOTION_CLASSIC_MAP["[偷笑]"] = R.drawable.d_touxiao
        EMOTION_CLASSIC_MAP["[笑cry]"] = R.drawable.d_xiaoku
        EMOTION_CLASSIC_MAP["[doge]"] = R.drawable.d_doge
        EMOTION_CLASSIC_MAP["[喵喵]"] = R.drawable.d_miao
        EMOTION_CLASSIC_MAP["[酷]"] = R.drawable.d_ku
        EMOTION_CLASSIC_MAP["[衰]"] = R.drawable.d_shuai
        EMOTION_CLASSIC_MAP["[闭嘴]"] = R.drawable.d_bizui
        EMOTION_CLASSIC_MAP["[鄙视]"] = R.drawable.d_bishi
        EMOTION_CLASSIC_MAP["[花心]"] = R.drawable.d_huaxin
        EMOTION_CLASSIC_MAP["[鼓掌]"] = R.drawable.d_guzhang
        EMOTION_CLASSIC_MAP["[悲伤]"] = R.drawable.d_beishang
        EMOTION_CLASSIC_MAP["[思考]"] = R.drawable.d_sikao
        EMOTION_CLASSIC_MAP["[生病]"] = R.drawable.d_shengbing
        EMOTION_CLASSIC_MAP["[亲亲]"] = R.drawable.d_qinqin
        EMOTION_CLASSIC_MAP["[怒骂]"] = R.drawable.d_numa
        EMOTION_CLASSIC_MAP["[太开心]"] = R.drawable.d_taikaixin
        EMOTION_CLASSIC_MAP["[懒得理你]"] = R.drawable.d_landelini
        EMOTION_CLASSIC_MAP["[右哼哼]"] = R.drawable.d_youhengheng
        EMOTION_CLASSIC_MAP["[左哼哼]"] = R.drawable.d_zuohengheng
        EMOTION_CLASSIC_MAP["[嘘]"] = R.drawable.d_xu
        EMOTION_CLASSIC_MAP["[委屈]"] = R.drawable.d_weiqu
        EMOTION_CLASSIC_MAP["[吐]"] = R.drawable.d_tu
        EMOTION_CLASSIC_MAP["[可怜]"] = R.drawable.d_kelian
        EMOTION_CLASSIC_MAP["[打哈气]"] = R.drawable.d_dahaqi
        EMOTION_CLASSIC_MAP["[挤眼]"] = R.drawable.d_jiyan
        EMOTION_CLASSIC_MAP["[失望]"] = R.drawable.d_shiwang
        EMOTION_CLASSIC_MAP["[顶]"] = R.drawable.d_ding
        EMOTION_CLASSIC_MAP["[疑问]"] = R.drawable.d_yiwen
        EMOTION_CLASSIC_MAP["[困]"] = R.drawable.d_kun
        EMOTION_CLASSIC_MAP["[感冒]"] = R.drawable.d_ganmao
        EMOTION_CLASSIC_MAP["[拜拜]"] = R.drawable.d_baibai
        EMOTION_CLASSIC_MAP["[黑线]"] = R.drawable.d_heixian
        EMOTION_CLASSIC_MAP["[阴险]"] = R.drawable.d_yinxian
        EMOTION_CLASSIC_MAP["[打脸]"] = R.drawable.d_dalian
        EMOTION_CLASSIC_MAP["[傻眼]"] = R.drawable.d_shayan
        EMOTION_CLASSIC_MAP["[猪头]"] = R.drawable.d_zhutou
        EMOTION_CLASSIC_MAP["[熊猫]"] = R.drawable.d_xiongmao
        EMOTION_CLASSIC_MAP["[兔子]"] = R.drawable.d_tuzi
    }

    /**
     * 根据名称获取当前表情图标R值
     * @param type 表情类型标志符
     * @param key 名称
     * @return
     */
    fun getImgByName(type: Int, key: String?): Int {
        var integer: Int? = null
        when (type) {
            EMOTION_CLASSIC_TYPE -> integer = EMOTION_CLASSIC_MAP[key]
            else -> L.e("the emojiMap is null!! Handle Yourself ")
        }
        return integer ?: -1
    }

    /**
     * 根据类型获取表情数据
     * @param EmotionType
     * @return
     */
    fun getEmojiMap(EmotionType: Int): ArrayMap<String, Int>? {
        return when (EmotionType) {
            EMOTION_CLASSIC_TYPE -> EMOTION_CLASSIC_MAP
            else -> EMPTY_MAP
        }
    }

}